﻿using System;
using System.Collections.Generic;
using System.Drawing.Design;
using System.Linq;
using System.Text;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Xml.Serialization;
using Microsoft.Practices.Modeling.ExtensionProvider.Metadata;
using Microsoft.Practices.Services.ItineraryDsl;
using Microsoft.Practices.Modeling.ExtensionProvider.Extension;
using Microsoft.Practices.Modeling.Common;
using Microsoft.Practices.Modeling.Common.Security;
using Microsoft.Practices.Modeling.Common.Design;
using Microsoft.Practices.Modeling.Services.Design;
using Microsoft.Practices.Modeling.Validation;
using Microsoft.Practices.EnterpriseLibrary.Validation.Validators;
using BizTalk.ESB.Extensions.Helpers;

namespace BizTalk.ESB.Extensions.ResolverExtenders
{
    [Serializable]
    [ObjectExtender(typeof(Resolver))]
    public class StaticPropertyPromotionResolverExtender : ObjectExtender<Resolver>
    {

        private List<BaseSourceMapping> _mappings = new List<BaseSourceMapping>();
        [Category(StaticContextResolverExtenderProvider.ExtensionProviderPropertyCategory),
            Description("Defines which properties to promote and what data to use for each property value. To map from message content, use a value of 'XPATH{...}'. To map from message context, use a value of CONTEXT{namespace/propertyname}.  To use the current date-time, use a value of NOW.  To generate a GUID, use a value of GUID.  For literal strings, use a value of STRING{...}. "),
            DisplayName("Data Tracking Configuration"),
            Editor(typeof(ItineraryServiceDataMappingEditor), typeof(UITypeEditor)),
            EncryptProperty(typeof(ItineraryModel)),
            ReadOnly(false), Browsable(true)]
        [XmlElement]
        public List<BaseSourceMapping> TrackingConfig
        {
            get
            {
                return _mappings;
            }
            set
            {
                _mappings = value;
            }
        }
    }

    [Serializable]
    [ObjectExtender(typeof(Resolver))]
    public class BrePropertyPromotionResolverExtender : ObjectExtender<Resolver>
    {
        [EditorOutputProperty("Version", "Version", new String[] { }),
            Category("Extender Settings"),
            Description("Specifies the policy"),
            DisplayName("Policy"),
            ReadOnly(false),
            Browsable(true),
            Editor(typeof(BiztalkPolicyEditor), typeof(UITypeEditor)),
            TypeConverter(typeof(TypeConverter))]
        public String Policy { get; set; }

        [ReadOnly(false),
            DisplayName("Version"),
            Category("Extender Settings"),
            Description("Specifies the policy version"),
            Browsable(true)]
        public VersionNumber Version { get; set; }

        [Description("Used to recognize the Document Type.  Note: This is a messaging only scenario and is not suppored for Orchestration. i.e. - in case of orchestration, the field will always be set to 'false'."),
            DisplayName("Recognize Message Format"),
            Browsable(true),
            ReadOnly(false),
            Category("Extender Settings")]
        public Boolean RecognizeMessageFormat { get; set; }

        [Description("Determines if the message will be sent to the policy as a fact."),
            ReadOnly(false),
            Browsable(true),
            Category("Extender Settings"),
            DisplayName("UseMsg")]
        public Boolean UseMsg { get; set; }

        [Description("Determines if the message context will be sent to the policy as a fact."),
            ReadOnly(false),
            Browsable(true),
            Category("Extender Settings"),
            DisplayName("UseMsgContext")]
        public Boolean UseMsgContext { get; set; }
    }
}
